<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-teacher-add">
				<div class="form-group">
					<label class="col-sm-3 control-label">部门名称：</label>
					<div class="col-sm-8">
						<input class="form-control" type="hidden" name="deptId" readonly="true" id="treeId">
						<input name="deptName" class="form-control" type="text" onclick="selectDeptTree()" readonly="true" id="treeName">
					</div>
				</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">工作岗位：</label>
				<div class="col-sm-8">
					<input id="jobPost" name="jobPost" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">教师名字：</label>
				<div class="col-sm-8">
					<input id="name" name="name" class="form-control" type="text" >
				</div>
			</div>
			<div class="form-group">
			<label class="col-sm-3 control-label">性别：</label>
			<div class="col-sm-8">
				<select id="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
					<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" ></option>
				</select>
			</div>
		</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">电话：</label>
				<div class="col-sm-8">
					<input id="telephone" name="telephone" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">民族：</label>
				<div class="col-sm-8">
					<input id="nation" name="nation" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">出生日期：</label>
				<div class="col-sm-8">
					<input id="dateBirth" name="dateBirth" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">身高：</label>
				<div class="col-sm-8">
					<input id="height" name="height" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">政治面貌：</label>
				<div class="col-sm-8">
					<input id="politics" name="politics" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">婚姻：</label>
				<div class="col-sm-8">
					<select id="marriage" class="form-control m-b" th:with="type=${@dict.getType('zl_xyzlb_huny')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">最高学历：</label>
				<div class="col-sm-8">
					<input id="education" name="education" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">毕业院校：</label>
				<div class="col-sm-8">
					<input id="graduation" name="graduation" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">专业：</label>
				<div class="col-sm-8">
					<input id="major" name="major" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">生育状况：</label>
				<div class="col-sm-8">
					<input id="birth" name="birth" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">办公技能：</label>
				<div class="col-sm-8">
					<input id="skills" name="skills" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">重大病史：</label>
				<div class="col-sm-8">
					<select id="illness" class="form-control m-b" th:with="type=${@dict.getType('zl_hyzlb_xiaoh')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">亲属是否就职本公司：</label>
				<div class="col-sm-8">
					<select id="relatives" class="form-control m-b" th:with="type=${@dict.getType('sys_yes_no')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">身份证号：</label>
				<div class="col-sm-8">
					<input id="idnumber" name="idnumber" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">户籍地址：</label>
				<div class="col-sm-8">
					<input id="address" name="address" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">参加工作年限：</label>
				<div class="col-sm-8">
					<input id="jobtime" name="jobtime" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">现居住地址：</label>
				<div class="col-sm-8">
					<input id="live" name="live" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">邮箱：</label>
				<div class="col-sm-8">
					<input id="mailbox" name="mailbox" class="form-control" type="email">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">个人特长：</label>
				<div class="col-sm-8">
					<input id="speciality" name="speciality" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">自我描述：</label>
				<div class="col-sm-8">
					<input id="miaoshu" name="miaoshu" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" class="form-control" type="text">
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
        $("#form-teacher-add").validate({
            rules:{

                mailbox:{
                    required:true,
                    email:true,
                    remote: {
                        url: ctx + "project/teacher/checkEmailUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            name: function () {
                                return $.common.trim($("#mailbox").val());
                            }
                        },
                        dataFilter: function (data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
                telephone:{
                    required:true,
                    isPhone:true,
                    remote: {
                        url: ctx + "project/teacher/checkPhoneUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            name: function () {
                                return $.common.trim($("#telephone").val());
                            }
                        },
                        dataFilter: function (data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
            },
            messages: {
                "email": {
                    remote: "Email已经存在"
                },
                "phonenumber":{
                    remote: "手机号码已经存在"
                }
            }
        });

        function submitHandler() {
            if ($.validate.form()) {
                add();
            }
        }

        function add() {

            var deptId = $("input[name='deptId']").val();
            var deptName = $("input[name='deptName']").val();
            var docNo = $("input[name='docNo']").val();
            var jobPost = $("input[name='jobPost']").val();
            var name = $("input[name='name']").val();
            var telephone = $("input[name='telephone']").val();
            var dateBirth = $("input[name='dateBirth']").val();
            var height = $("input[name='height']").val();
            var politics = $("input[name='politics']").val();
            var marriage = $("#marriage option:selected").val();
            var education = $("input[name='education']").val();
            var graduation = $("input[name='graduation']").val();
            var major = $("input[name='major']").val();
            var birth = $("input[name='birth']").val();
            var skills = $("input[name='skills']").val();
            var illness = $("#illness option:selected").val();
            var relatives = $("#relatives option:selected").val();
            var idnumber = $("input[name='idnumber']").val();
            var address = $("input[name='address']").val();
            var jobtime = $("input[name='jobtime']").val();
            var mailbox = $("input[name='mailbox']").val();
            var miaoshu = $("input[name='miaoshu']").val();
            var live = $("input[name='live']").val();
            var speciality = $("input[name='speciality']").val();
            var remark = $("input[name='remark']").val();


            $.ajax({
                cache : true,
                type : "POST",
                url : ctx + "project/teacher/add",
                data : {
                    "deptId":deptId,
                    "deptName":deptName,
                    "docNo":docNo,
                    "jobPost":jobPost,
                    "name":name,
                    "telephone":telephone,
                    "dateBirth":dateBirth,
                    "height":height,
                    "politics":politics,
                    "marriage":marriage,
                    "education":education,
                    "graduation":graduation,
                    "major":major,
                    "birth":birth,
                    "skills":skills,
                    "illness":illness,
                    "relatives":relatives,
                    "idnumber":idnumber,
                    "jobtime":jobtime,
                    "mailbox":mailbox,
                    "speciality":speciality,
                    "miaoshu":miaoshu,
                    "live":live,
                    "address":address,
                    "remark":remark,


                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.saveSuccess(data);
                }
            });
        }

        /*用户管理-新增-选择部门树*/
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: ctx + "system/dept/selectDeptTree/" + deptId,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
            }
        }


	</script>
</body>
</html>
